package com.jacklin.order.domain;

import lombok.Data;
import org.jacklin.common.dto.OrderDTO;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @describe: 订单服务
 * @author: jacklin
 * @date: 2022-03-24 23:14
 */
@Data
public class Orders implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer id;
    //商品ID
    private String productId;
    //商品数量
    private Integer sum;
    //金额
    private BigDecimal amount;
    //账户ID
    private String accountId;
    //创建时间
    private LocalDateTime createTime;
    //更新时间
    private LocalDateTime updateTime;

    public static Orders buildOrder(OrderDTO orderDTO) {
        Orders orders = new Orders();
        orders.setProductId(orderDTO.getProductId());
        orders.setSum(orderDTO.getProductCount());
        orders.setAmount(orderDTO.getOrderAmount());
        orders.setAccountId(orderDTO.getAccountId());
        orders.setCreateTime(LocalDateTime.now());
        orders.setUpdateTime(LocalDateTime.now());
        return orders;
    }

}
